angular.module('multi-select-tree').run(['$templateCache', function($templateCache) {
  'use strict';

  $templateCache.put('src/multi-select-tree.tpl.html',
    "<div class='tree-control'>" +
    "    <div class='tree-input' ng-click='onControlClicked($event)'>" +
    "        <span ng-show='crtValue'>{{crtValue}}</span>" +
    "        <span ng-show='crtValue && crtValue != defaultLabel' class='selected-item-close' ng-click='deselectItem(\"\", $event)' style='width: 20px; corsour: pointer; font-weight: bold; display: inline-block; padding: 2px; text-align: center;'>x</span>" +
    "        <span ng-show='crtValue' class='caret'></span>" +
    "        <span ng-show='!crtValue' ng-if='selectedItems.length == 0' class='selected-items'>" +
    "            <span ng-bind='defaultLabel'></span><span class='caret'></span>" +
    "        </span>" +
    "        <span ng-show='!crtValue' ng-if='selectedItems.length > 0' class='selected-items'>" +
    "            <span ng-repeat='selectedItem in selectedItems' class='selected-item'> " +
    "                {{selectedItem.name}} "+
    "                <span class='selected-item-close' ng-click='deselectItem(selectedItem, $event)'></span>" +
    "            </span>" +
    "            <span class='caret'></span>" +
    "        </span>" +
    "    </div>" +
    "    <div class='tree-view' ng-show='showTree'>" +
    "        <div class='helper-container'>" +
    "             <div class='select-tree-line' data-ng-if='switchView'>" +
    "                 <button type='button' ng-click='switchCurrentView($event);' class='helper-button'>{{switchViewLabel}}</button>" +
    "             </div>" +
    "            <div class='select-tree-line'>" +
    "                <input placeholder='Search...' type='text' ng-model='filterKeyword' ng-click='onFilterClicked($event)' class='input-filter'>" +
    "                <span class='clear-button' ng-click='clearFilter($event)'> " +
    "                    <span class='item-close'></span>" +
    "                </span>" +
    "            </div>" +
    "        </div>" +
    "        <ul class='tree-container'>" +
    "            <tree-item class='top-level' ng-repeat='item in inputModel' item='item' ng-show='!item.isFiltered'" +
    "                       use-callback='useCallback' can-select-item='canSelectItem'" +
    "                       multi-select='multiSelect' item-selected='itemSelected(item)'" +
    "                       on-active-item='onActiveItem(item)' select-only-leafs='selectOnlyLeafs' add-item='addItem'></tree-item>" +
    "        </ul>" +
    "    </div>" +
    "</div>"
  );


  $templateCache.put('src/tree-item.tpl.html',
      "<li>" +
      "    <div class='item-container' ng-class=\"{active: item.isActive}\" ng-mouseover='onMouseOver(item, $event)'>" +
      "        <span ng-if='showExpand(item)' class='expand' ng-class=\"{'expand-opened': item.isExpanded}\" ng-click='onExpandClicked(item, $event)'></span>" +
      "        <div class='item-details' style='width: calc(100% - 80px);' data-id='{{item.id}}' ng-click='clickSelectItem(item, $event)' >" +
      "            <input class='tree-checkbox' type='checkbox' ng-if='showCheckbox()' ng-checked='item.selected'>" +
      "            <input class='edit-item' type='text' style='color: #444;' ng-show='item.isEdit' ng-model='itemValue' ng-click='itemInputClick($event)'>" +
      "            <span ng-show='!item.isEdit && item.nodeType == \"page\"'>P：{{item.name}}</span>" +
      "            <span ng-show='!item.isEdit && item.nodeType == \"menu\"'>M：{{item.name}}</span>" +
      "            <span ng-show='!item.isEdit && !item.nodeType'>{{item.name}}</span>" +
      "        </div>" + 
      "        <div style='width: 50px; float: right;'>" +
      "            <i class='fa fa-edit pull-right' ng-show='!item.isEdit' ng-if='addItem' ng-click='onUpdateClick(item, item.children, $event)'></i>" +
      "            <i class='fa fa-save pull-right' ng-show='item.isEdit' ng-click='onSaveClick(item, item.children, $event)'></i>" +
      "            <i class='fa fa-rotate-left pull-right' ng-show='item.isEdit' ng-click='onCancelClick(item, item.children, $event)'></i>" +
      "            <i class='fa fa-plus pull-right' ng-show='!item.isEdit' ng-if='addItem' ng-click='onAddClick(item, item.children, $event)'></i>" +
      "        </div>" +
      "    </div>" +
      "    <ul ng-repeat='child in item.children' ng-if='item.isExpanded'>" +
      "        <tree-item item='child' item-selected='subItemSelected(item)' ng-show='!child.isFiltered' use-callback='useCallback' can-select-item='canSelectItem' multi-select='multiSelect' on-active-item='activeSubItem(item, $event)' add-item='addItem'></tree-item>" +
      "    </ul>" +
      "</li>" 
  );

}]);
